package cn.cdeden.knowledge.controller.Individual;

//import com.cdyd.ecm.annotation.Log;
import cn.cdeden.common.core.domain.R;
import cn.cdeden.common.core.utils.page.TableDataInfo;
import cn.cdeden.knowledge.domain.EnterpriseFolderTree;
import cn.cdeden.knowledge.domain.dto.EnterpriseFilesTreeDto;
import cn.cdeden.knowledge.domain.dto.EnterpriseFolderTreeDto;
import cn.cdeden.knowledge.domain.dto.EnterpriseFolderTreeQueryParam;
import cn.cdeden.knowledge.domain.vo.EnterpriseFolderTreeVo;
import cn.cdeden.knowledge.service.EnterpriseFilesTreeService;
import cn.cdeden.knowledge.service.EnterpriseFolderTreeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

/**
* @author GW
* @date 2023-03-27
**/
@Controller
@Slf4j
@RestController
@RequiredArgsConstructor
//@Api(tags = "企业模板管理")
@RequestMapping("/api/enterpriseFolderTree")
public class EnterpriseFolderTreeController {

    private final EnterpriseFolderTreeService enterpriseFolderTreeService;
    @GetMapping
//    @Log("查询所有文件夹模板")
//    @ApiOperation("查询所有文件夹模板")
    public R<TableDataInfo<EnterpriseFolderTreeDto>> query(EnterpriseFolderTreeQueryParam query, Pageable pageable){
        TableDataInfo<EnterpriseFolderTreeDto> info = enterpriseFolderTreeService.queryAll(query,pageable);
//        List<EnterpriseFolderTreeDto> content2 = info.getRows();
//        for (EnterpriseFolderTreeDto enterpriseFolderTreeDto :content2 ) {
//            enterpriseFolderTreeDto.setUrl(ImageFileUrlUtil.imageFile(enterpriseFolderTreeDto.getUrl()));

//        }
        return R.ok(info);
    }

    @GetMapping("/createByEnterpriseId")
//     @Log("新增文件夹模板")
//    @ApiOperation("新增文件夹模板")
    public R createByEnterpriseId(EnterpriseFolderTreeVo enterpriseFolderTreeVo){
        enterpriseFolderTreeService.createByEnterpriseId(enterpriseFolderTreeVo);
        return R.ok();
    }


    /*@GetMapping("/getFolder")
//    @Log("查询模板下所有文件夹")
//    @ApiOperation("查询模板下所有文件夹")
    public BaseRespResult<EnterpriseFilesTreeDto> getFolder(Long templateId){
        EnterpriseFilesTreeDto folder = enterpriseFolderTreeService.getFolder(templateId);
        return BaseRespResult.successResult(folder);
    }*/
    @GetMapping("/selectNext")
//    @Log("查询模板下所有文件夹")
//    @ApiOperation("查询模板下所有文件夹")
    public R<EnterpriseFolderTreeDto> Folder(Long id){
        return R.ok(enterpriseFolderTreeService.selectNext(id));
    }

//    @PutMapping
//    @Log("修改文件夹模板")
//    @ApiOperation("修改文件夹模板")
//    public BaseRespResult update(@Validated @RequestBody EnterpriseFolderTreeDto resources){
//        return BaseRespResult.successResult(enterpriseFolderTreeService.updateById(resources));
//    }


    /*
//    @Log("导出文件夹模板")
//    @ApiOperation("导出文件夹模板")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('enterpriseFolderTree:list')")
    public void download(HttpServletResponse response, EnterpriseFolderTreeQueryParam query) throws IOException {
        enterpriseFolderTreeService.download(enterpriseFolderTreeService.queryAll(query), response);
    }*/
}
